gtk_container_add (GTK_CONTAINER (hbox), image);
/* make image a drag source */
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-begin",
G_CALLBACK (drag_begin), image);
/* accept drops on image */
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
- NULL, 0, GDK_ACTION_COPY);
+ NULL, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (image);
g_signal_connect (image, "drag-data-received",
G_CALLBACK (drag_data_received), image);
gtk_container_add (GTK_CONTAINER (hbox), image);
/* make image a drag source */
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-begin",
G_CALLBACK (drag_begin), image);
/* accept drops on image */
gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL,
- NULL, 0, GDK_ACTION_COPY);
+ NULL, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (image);
g_signal_connect (image, "drag-data-received",
G_CALLBACK (drag_data_received), image);
static void
setup_image_dnd (GtkWidget *image)
{
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag-data-get", G_CALLBACK (get_image_data), NULL);
}
setup_scalable_image_dnd (GtkWidget *image)
{
GtkWidget *parent;
+ GtkTargetList *targets;
parent = gtk_widget_get_parent (image);
+ targets = gtk_target_list_new (target_table, G_N_ELEMENTS (target_table));
gtk_drag_source_set (parent, GDK_BUTTON1_MASK,
- target_table, G_N_ELEMENTS (target_table),
+ targets,
GDK_ACTION_COPY);
+ gtk_target_list_unref (targets);
g_signal_connect (parent, "drag-data-get", G_CALLBACK (get_scalable_image_data), NULL);
}
icon_browser_window_init (IconBrowserWindow *win)
{
GtkTargetList *list;
- GtkTargetEntry *targets;
- gint n_targets;
gtk_widget_init_template (GTK_WIDGET (win));
list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_text_targets (list, 0);
- targets = gtk_target_table_new_from_list (list, &n_targets);
- gtk_target_list_unref (list);
-
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (win->list),
GDK_BUTTON1_MASK,
- targets, n_targets,
+ list,
GDK_ACTION_COPY);
-
- gtk_target_table_free (targets, n_targets);
+ gtk_target_list_unref (list);
setup_image_dnd (win->image1);
setup_image_dnd (win->image2);
priv->in_drag = 0;
priv->drag_highlight = 0;
- gtk_drag_dest_set (widget, 0, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_dest_set (widget, 0, NULL, GDK_ACTION_COPY);
gtk_drag_dest_add_text_targets (widget);
priv->year_before = 0;
PangoLayout *layout;
PangoRectangle rect;
GtkStyleContext *context;
+ GtkTargetList *targets;
gtk_widget_set_has_window (GTK_WIDGET (button), FALSE);
priv->rgba.alpha = 1;
priv->use_alpha = FALSE;
+ targets = gtk_target_list_new (drop_types, G_N_ELEMENTS (drop_types));
gtk_drag_dest_set (priv->button,
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_DROP,
- drop_types, 1, GDK_ACTION_COPY);
+ targets,
+ GDK_ACTION_COPY);
gtk_drag_source_set (priv->button,
GDK_BUTTON1_MASK|GDK_BUTTON3_MASK,
- drop_types, 1,
+ targets,
GDK_ACTION_COPY);
+ gtk_target_list_unref (targets);
g_signal_connect (priv->button, "drag-begin",
G_CALLBACK (gtk_color_button_drag_begin), button);
g_signal_connect (priv->button, "drag-data-received",
if (!swatch->priv->has_color)
{
+ GtkTargetList *targets = gtk_target_list_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
gtk_drag_source_set (GTK_WIDGET (swatch),
GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
- dnd_targets, G_N_ELEMENTS (dnd_targets),
+ targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ gtk_target_list_unref (targets);
}
swatch->priv->has_color = TRUE;
{
if (can_drop)
{
+ GtkTargetList *targets = gtk_target_list_new (dnd_targets, G_N_ELEMENTS (dnd_targets));
gtk_drag_dest_set (GTK_WIDGET (swatch),
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_DROP,
- dnd_targets, G_N_ELEMENTS (dnd_targets),
+ targets,
GDK_ACTION_COPY);
+ gtk_target_list_unref (targets);
}
else
{
* gtk_drag_dest_set: (method)
* @widget: a #GtkWidget
* @flags: which types of default drag behavior to use
- * @targets: (allow-none) (array length=n_targets): a pointer to an array of
- * #GtkTargetEntrys indicating the drop types that this @widget will
+ * @targets: (allow-none): the drop types that this @widget will
* accept, or %NULL. Later you can access the list with
* gtk_drag_dest_get_target_list() and gtk_drag_dest_find_target().
- * @n_targets: the number of entries in @targets
* @actions: a bitmask of possible actions for a drop onto this @widget.
*
* Sets a widget as a potential drop destination, and adds default behaviors.
* ]|
*/
void
-gtk_drag_dest_set (GtkWidget *widget,
- GtkDestDefaults flags,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
+gtk_drag_dest_set (GtkWidget *widget,
+ GtkDestDefaults flags,
+ GtkTargetList *targets,
+ GdkDragAction actions)
{
GtkDragDestSite *site;
site->flags = flags;
site->have_drag = FALSE;
if (targets)
- site->target_list = gtk_target_list_new (targets, n_targets);
+ site->target_list = gtk_target_list_ref (targets);
else
site->target_list = NULL;
site->actions = actions;
GDK_AVAILABLE_IN_ALL
void gtk_drag_dest_set (GtkWidget *widget,
GtkDestDefaults flags,
- const GtkTargetEntry *targets,
- gint n_targets,
+ GtkTargetList *targets,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
* gtk_drag_source_set: (method)
* @widget: a #GtkWidget
* @start_button_mask: the bitmask of buttons that can start the drag
- * @targets: (allow-none) (array length=n_targets): the table of targets
- * that the drag will support, may be %NULL
- * @n_targets: the number of items in @targets
+ * @targets: (allow-none): the targets that the drag will support,
+ * may be %NULL
* @actions: the bitmask of possible actions for a drag from this widget
*
* Sets up a widget so that GTK+ will start a drag operation when the user
* clicks and drags on the widget. The widget must have a window.
*/
void
-gtk_drag_source_set (GtkWidget *widget,
- GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
+gtk_drag_source_set (GtkWidget *widget,
+ GdkModifierType start_button_mask,
+ GtkTargetList *targets,
+ GdkDragAction actions)
{
GtkDragSourceSite *site;
site->start_button_mask = start_button_mask;
- site->target_list = gtk_target_list_new (targets, n_targets);
+ if (targets)
+ site->target_list = gtk_target_list_ref (targets);
+ else
+ site->target_list = NULL;
site->actions = actions;
}
GDK_AVAILABLE_IN_ALL
void gtk_drag_source_set (GtkWidget *widget,
GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
+ GtkTargetList *targets,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
priv->caps_lock_warning = TRUE;
priv->caps_lock_warning_shown = FALSE;
- gtk_drag_dest_set (GTK_WIDGET (entry), 0, NULL, 0,
+ gtk_drag_dest_set (GTK_WIDGET (entry), 0, NULL,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_drag_dest_add_text_targets (GTK_WIDGET (entry));
GTK_STYLE_CLASS_HORIZONTAL);
gtk_container_add (GTK_CONTAINER (priv->title_widget), priv->arrow_widget);
- gtk_drag_dest_set (GTK_WIDGET (expander), 0, NULL, 0, 0);
+ gtk_drag_dest_set (GTK_WIDGET (expander), 0, NULL, 0);
gtk_drag_dest_set_track_motion (GTK_WIDGET (expander), TRUE);
priv->multipress_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (expander));
NULL, NULL);
/* DnD */
- gtk_drag_dest_set (GTK_WIDGET (button),
- (GTK_DEST_DEFAULT_ALL),
- NULL, 0,
- GDK_ACTION_COPY);
target_list = gtk_target_list_new (NULL, 0);
gtk_target_list_add_uri_targets (target_list, TEXT_URI_LIST);
gtk_target_list_add_text_targets (target_list, TEXT_PLAIN);
- gtk_drag_dest_set_target_list (GTK_WIDGET (button), target_list);
+ gtk_drag_dest_set (GTK_WIDGET (button),
+ (GTK_DEST_DEFAULT_ALL),
+ target_list,
+ GDK_ACTION_COPY);
gtk_target_list_unref (target_list);
}
impl, NULL);
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (impl->priv->browse_files_tree_view),
GDK_BUTTON1_MASK,
- NULL, 0,
+ NULL,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_drag_source_add_uri_targets (impl->priv->browse_files_tree_view);
gtk_drag_dest_set (impl->priv->browse_files_tree_view,
GTK_DEST_DEFAULT_ALL,
- NULL, 0,
+ NULL,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_drag_dest_add_uri_targets (impl->priv->browse_files_tree_view);
* gtk_icon_view_enable_model_drag_source:
* @icon_view: a #GtkIconView
* @start_button_mask: Mask of allowed buttons to start drag
- * @targets: (array length=n_targets): the table of targets that the drag will
- * support
- * @n_targets: the number of items in @targets
+ * @targets: the targets that the drag will support
* @actions: the bitmask of possible actions for a drag from this
* widget
*
void
gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
+ GtkTargetList *targets,
GdkDragAction actions)
{
g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
- gtk_drag_source_set (GTK_WIDGET (icon_view), 0, targets, n_targets, actions);
+ gtk_drag_source_set (GTK_WIDGET (icon_view), 0, targets, actions);
icon_view->priv->start_button_mask = start_button_mask;
icon_view->priv->source_actions = actions;
/**
* gtk_icon_view_enable_model_drag_dest:
* @icon_view: a #GtkIconView
- * @targets: (array length=n_targets): the table of targets that the drag will
- * support
- * @n_targets: the number of items in @targets
+ * @targets: the targets that the drag will support
* @actions: the bitmask of possible actions for a drag to this
* widget
*
* Since: 2.8
**/
void
-gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
+gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
+ GtkTargetList *targets,
+ GdkDragAction actions)
{
g_return_if_fail (GTK_IS_ICON_VIEW (icon_view));
- gtk_drag_dest_set (GTK_WIDGET (icon_view), 0, targets, n_targets, actions);
+ gtk_drag_dest_set (GTK_WIDGET (icon_view), 0, targets, actions);
icon_view->priv->dest_actions = actions;
if (reorderable)
{
+ GtkTargetList *targets = gtk_target_list_new (item_targets, G_N_ELEMENTS (item_targets));
gtk_icon_view_enable_model_drag_source (icon_view,
GDK_BUTTON1_MASK,
- item_targets,
- G_N_ELEMENTS (item_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_icon_view_enable_model_drag_dest (icon_view,
- item_targets,
- G_N_ELEMENTS (item_targets),
+ targets,
GDK_ACTION_MOVE);
+ gtk_target_list_unref (targets);
}
else
{
GDK_AVAILABLE_IN_ALL
void gtk_icon_view_enable_model_drag_source (GtkIconView *icon_view,
GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
+ GtkTargetList *targets,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
void gtk_icon_view_enable_model_drag_dest (GtkIconView *icon_view,
- const GtkTargetEntry *targets,
- gint n_targets,
+ GtkTargetList *targets,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
void gtk_icon_view_unset_model_drag_source (GtkIconView *icon_view);
{
GtkLinkButtonPrivate *priv = gtk_link_button_get_instance_private (link_button);
GtkStyleContext *context;
+ GtkTargetList *targets;
link_button->priv = priv;
G_CALLBACK (gtk_link_button_query_tooltip_cb), NULL);
/* enable drag source */
+ targets = gtk_target_list_new (link_drop_types, G_N_ELEMENTS (link_drop_types));
gtk_drag_source_set (GTK_WIDGET (link_button),
GDK_BUTTON1_MASK,
- link_drop_types, G_N_ELEMENTS (link_drop_types),
+ targets,
GDK_ACTION_COPY);
+ gtk_target_list_unref (targets);
priv->click_gesture = gtk_gesture_multi_press_new (GTK_WIDGET (link_button));
gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (priv->click_gesture), FALSE);
gtk_notebook_init (GtkNotebook *notebook)
{
GtkNotebookPrivate *priv;
+ GtkTargetList *targets;
gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE);
gtk_widget_set_has_window (GTK_WIDGET (notebook), FALSE);
else
priv->tabs_reversed = FALSE;
+ targets = gtk_target_list_new (dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets));
gtk_drag_dest_set (GTK_WIDGET (notebook), 0,
- dst_notebook_targets, G_N_ELEMENTS (dst_notebook_targets),
+ targets,
GDK_ACTION_MOVE);
+ gtk_target_list_unref (targets);
gtk_drag_dest_set_track_motion (GTK_WIDGET (notebook), TRUE);
gtk_drag_source_set (button_data->button,
GDK_BUTTON1_MASK,
- NULL, 0,
+ NULL,
GDK_ACTION_COPY);
gtk_drag_source_add_uri_targets (button_data->button);
g_signal_connect (button_data->button, "drag-data-get",
/* DND support */
gtk_drag_dest_set (sidebar->list_box,
0,
- NULL, 0,
+ NULL,
GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK);
target_list = gtk_target_list_new (dnd_drop_targets, G_N_ELEMENTS (dnd_drop_targets));
gtk_target_list_add_uri_targets (target_list, DND_TEXT_URI_LIST);
NULL);
gtk_drag_source_set (priv->recent_view,
GDK_BUTTON1_MASK,
- NULL, 0,
+ NULL,
GDK_ACTION_COPY);
gtk_drag_source_add_uri_targets (priv->recent_view);
}
gtk_orientable_set_orientation (GTK_ORIENTABLE (switcher), GTK_ORIENTATION_HORIZONTAL);
- gtk_drag_dest_set (GTK_WIDGET (switcher), 0, NULL, 0, 0);
+ gtk_drag_dest_set (GTK_WIDGET (switcher), 0, NULL, 0);
gtk_drag_dest_set_track_motion (GTK_WIDGET (switcher), TRUE);
}
priv->scroll_after_paste = TRUE;
- gtk_drag_dest_set (widget, 0, NULL, 0,
+ gtk_drag_dest_set (widget, 0, NULL,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
target_list = gtk_target_list_new (NULL, 0);
{
GtkTargetEntry entries[G_N_ELEMENTS (dnd_targets)];
gint n_entries = 0;
+ GtkTargetList *list;
g_return_if_fail (GTK_IS_TOOL_PALETTE (palette));
g_return_if_fail (GTK_IS_WIDGET (widget));
if (targets & GTK_TOOL_PALETTE_DRAG_GROUPS)
entries[n_entries++] = dnd_targets[1];
- gtk_drag_dest_set (widget, flags, entries, n_entries, actions);
+ list = gtk_target_list_new (entries, n_entries);
+ gtk_drag_dest_set (widget, flags, list, actions);
+ gtk_target_list_unref (list);
}
void
if (GTK_IS_TOOL_ITEM (child) &&
(palette->priv->drag_source & GTK_TOOL_PALETTE_DRAG_ITEMS))
{
+ GtkTargetList *targets;
+
/* Connect to child instead of the item itself,
* to work arround bug 510377.
*/
if (!child)
return;
+ targets = gtk_target_list_new (&dnd_targets[0], 1);
gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
- &dnd_targets[0], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ gtk_target_list_unref (targets);
g_signal_connect (child, "drag-data-get",
G_CALLBACK (gtk_tool_palette_item_drag_data_get),
else if (GTK_IS_BUTTON (child) &&
(palette->priv->drag_source & GTK_TOOL_PALETTE_DRAG_GROUPS))
{
+ GtkTargetList *targets;
+
+ targets = gtk_target_list_new (&dnd_targets[1], 1);
gtk_drag_source_set (child, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
- &dnd_targets[1], 1, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ targets, GDK_ACTION_COPY | GDK_ACTION_MOVE);
+ gtk_target_list_unref (targets);
g_signal_connect (child, "drag-data-get",
G_CALLBACK (gtk_tool_palette_child_drag_data_get),
const GtkTargetEntry row_targets[] = {
{ (char *) "GTK_TREE_MODEL_ROW", GTK_TARGET_SAME_WIDGET, 0 }
};
+ GtkTargetList *targets;
+
+ targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
gtk_tree_view_enable_model_drag_source (tree_view,
GDK_BUTTON1_MASK,
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_dest (tree_view,
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE);
}
else
* gtk_tree_view_enable_model_drag_source:
* @tree_view: a #GtkTreeView
* @start_button_mask: Mask of allowed buttons to start drag
- * @targets: (array length=n_targets): the table of targets that the drag will support
- * @n_targets: the number of items in @targets
+ * @targets: the targets that the drag will support
* @actions: the bitmask of possible actions for a drag from this
* widget
*
* method sets #GtkTreeView:reorderable to %FALSE.
**/
void
-gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
- GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
+gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
+ GdkModifierType start_button_mask,
+ GtkTargetList *targets,
+ GdkDragAction actions)
{
TreeViewDragInfo *di;
gtk_drag_source_set (GTK_WIDGET (tree_view),
0,
targets,
- n_targets,
actions);
di = ensure_info (tree_view);
/**
* gtk_tree_view_enable_model_drag_dest:
* @tree_view: a #GtkTreeView
- * @targets: (array length=n_targets): the table of targets that
- * the drag will support
+ * @targets: the targets that the drag will support
* @n_targets: the number of items in @targets
* @actions: the bitmask of possible actions for a drag from this
* widget
* this method sets #GtkTreeView:reorderable to %FALSE.
**/
void
-gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
- const GtkTargetEntry *targets,
- gint n_targets,
- GdkDragAction actions)
+gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
+ GtkTargetList *targets,
+ GdkDragAction actions)
{
TreeViewDragInfo *di;
gtk_drag_dest_set (GTK_WIDGET (tree_view),
0,
targets,
- n_targets,
actions);
di = ensure_info (tree_view);
GDK_AVAILABLE_IN_ALL
void gtk_tree_view_enable_model_drag_source (GtkTreeView *tree_view,
GdkModifierType start_button_mask,
- const GtkTargetEntry *targets,
- gint n_targets,
+ GtkTargetList *targets,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
void gtk_tree_view_enable_model_drag_dest (GtkTreeView *tree_view,
- const GtkTargetEntry *targets,
- gint n_targets,
+ GtkTargetList *targets,
GdkDragAction actions);
GDK_AVAILABLE_IN_ALL
void gtk_tree_view_unset_rows_drag_source (GtkTreeView *tree_view);
GtkWidget *widget;
GtkCssNode *widget_node;
GdkSeat *seat;
+ GtkTargetList *targets;
widget = GTK_WIDGET (window);
priv->scale = gtk_widget_get_scale_factor (widget);
+ targets = gtk_target_list_new (dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets));
gtk_drag_dest_set (GTK_WIDGET (window),
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
- dnd_dest_targets, G_N_ELEMENTS (dnd_dest_targets),
+ targets,
GDK_ACTION_MOVE);
+ gtk_target_list_unref (targets);
seat = gdk_display_get_default_seat (gtk_widget_get_display (widget));
g_signal_connect (seat, "device-removed",
GtkWidget *button;
GtkWidget *grid;
int i, j;
+ GtkTargetList *targets;
popup_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_position (GTK_WINDOW (popup_window), GTK_WIN_POS_MOUSE);
grid = gtk_grid_new ();
+ targets = gtk_target_list_new (target_table, n_targets - 1); /* no rootwin */
for (i=0; i<3; i++)
for (j=0; j<3; j++)
gtk_drag_dest_set (button,
GTK_DEST_DEFAULT_ALL,
- target_table, n_targets - 1, /* no rootwin */
+ targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (button, "drag_motion",
G_CALLBACK (popup_motion), NULL);
G_CALLBACK (popup_leave), NULL);
}
gtk_container_add (GTK_CONTAINER (popup_window), grid);
+ gtk_target_list_unref (targets);
}
gtk_widget_show (popup_window);
GtkWidget *pixmap;
GtkWidget *button;
GdkPixbuf *drag_icon;
+ GtkTargetList *targets;
test_init ();
label = gtk_label_new ("Drop Here\n");
+ targets = gtk_target_list_new (target_table, n_targets - 1); /* no rootwin */
gtk_drag_dest_set (label,
GTK_DEST_DEFAULT_ALL,
- target_table, n_targets - 1, /* no rootwin */
+ targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
g_signal_connect (label, "drag_data_received",
gtk_drag_dest_set (label,
GTK_DEST_DEFAULT_ALL,
- target_table, n_targets - 1, /* no rootwin */
+ targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_widget_set_hexpand (label, TRUE);
G_CALLBACK (popsite_motion), NULL);
g_signal_connect (label, "drag_leave",
G_CALLBACK (popsite_leave), NULL);
+ gtk_target_list_unref (targets);
pixmap = gtk_image_new_from_pixbuf (trashcan_closed);
- gtk_drag_dest_set (pixmap, 0, NULL, 0, 0);
+ gtk_drag_dest_set (pixmap, 0, NULL, 0);
gtk_widget_set_hexpand (pixmap, TRUE);
gtk_widget_set_vexpand (pixmap, TRUE);
gtk_grid_attach (GTK_GRID (grid), pixmap, 1, 0, 1, 1);
button = gtk_button_new_with_label ("Drag Here\n");
+ targets = gtk_target_list_new (target_table, n_targets);
gtk_drag_source_set (button, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
- target_table, n_targets,
+ targets,
GDK_ACTION_COPY | GDK_ACTION_MOVE);
gtk_drag_source_set_icon_pixbuf (button, drag_icon);
+ gtk_target_list_unref (targets);
g_object_unref (drag_icon);
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
update_source_target_list (image);
g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
g_signal_connect (image, "drag-begin", G_CALLBACK (image_drag_begin), image);
g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
- gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
update_dest_target_list (image);
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
update_source_target_list (image);
g_object_set_data (G_OBJECT (image), "hotspot", GINT_TO_POINTER (hotspot));
g_signal_connect (image, "drag-begin", G_CALLBACK (window_drag_begin), image);
g_signal_connect (image, "drag-data-get", G_CALLBACK (image_drag_data_get), image);
- gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_dest_set (image, GTK_DEST_DEFAULT_ALL, NULL, GDK_ACTION_COPY);
g_signal_connect (image, "drag-data-received", G_CALLBACK (image_drag_data_received), image);
update_dest_target_list (image);
spinner = gtk_spinner_new ();
gtk_spinner_start (GTK_SPINNER (spinner));
- gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
+ gtk_drag_source_set (spinner, GDK_BUTTON1_MASK, NULL, GDK_ACTION_COPY);
gtk_drag_source_add_text_targets (spinner);
g_signal_connect (spinner, "drag-begin", G_CALLBACK (spinner_drag_begin), spinner);
GtkTreeModel *model;
GtkCellRenderer *cell;
GtkTreeViewColumn *tvc;
+ GtkTargetList *targets;
#ifdef GTK_SRCDIR
g_chdir (GTK_SRCDIR);
#endif
/* Allow DND between the icon view and the tree view */
+ targets = gtk_target_list_new (item_targets, G_N_ELEMENTS (item_targets));
gtk_icon_view_enable_model_drag_source (GTK_ICON_VIEW (icon_list),
GDK_BUTTON1_MASK,
- item_targets,
- G_N_ELEMENTS (item_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_icon_view_enable_model_drag_dest (GTK_ICON_VIEW (icon_list),
- item_targets,
- G_N_ELEMENTS (item_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
GDK_BUTTON1_MASK,
- item_targets,
- G_N_ELEMENTS (item_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv),
- item_targets,
- G_N_ELEMENTS (item_targets),
+ targets,
GDK_ACTION_MOVE);
-
+ gtk_target_list_unref (targets);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_container_add (GTK_CONTAINER (scrolled_window), icon_list);
gtk_grid_attach (GTK_GRID (grid), image, 2, 1, 1, 1);
gtk_drag_source_set (image, GDK_BUTTON1_MASK,
- NULL, 0,
+ NULL,
GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (image);
g_signal_connect (image, "drag_begin", G_CALLBACK (drag_begin), image);
GTK_DEST_DEFAULT_MOTION |
GTK_DEST_DEFAULT_HIGHLIGHT |
GTK_DEST_DEFAULT_DROP,
- NULL, 0, GDK_ACTION_COPY);
+ NULL, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (image);
g_signal_connect (image, "drag_data_received",
G_CALLBACK (drag_data_received), image);
GtkCellRenderer *renderer;
GtkListStore *store;
GtkWidget *textview;
+ GtkTargetList *targets;
gint i;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (swindow);
treeview = gtk_tree_view_new ();
+ targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (treeview),
GDK_BUTTON1_MASK,
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (treeview),
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ gtk_target_list_unref (targets);
renderer = gtk_cell_renderer_text_new ();
g_object_set (renderer, "editable", TRUE, NULL);
create_row (const gchar *text)
{
GtkWidget *row, *box, *label, *image;
+ GtkTargetList *targets;
row = gtk_list_box_row_new ();
image = gtk_image_new_from_icon_name ("open-menu-symbolic", 1);
gtk_container_add (GTK_CONTAINER (box), label);
gtk_container_add (GTK_CONTAINER (box), image);
- gtk_drag_source_set (image, GDK_BUTTON1_MASK, entries, 1, GDK_ACTION_MOVE);
+ targets = gtk_target_list_new (entries, 1);
+
+ gtk_drag_source_set (image, GDK_BUTTON1_MASK, targets, GDK_ACTION_MOVE);
g_signal_connect (image, "drag-begin", G_CALLBACK (drag_begin), NULL);
g_signal_connect (image, "drag-data-get", G_CALLBACK (drag_data_get), NULL);
- gtk_drag_dest_set (row, GTK_DEST_DEFAULT_ALL, entries, 1, GDK_ACTION_MOVE);
+ gtk_drag_dest_set (row, GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_MOVE);
g_signal_connect (row, "drag-data-received", G_CALLBACK (drag_data_received), NULL);
+ gtk_target_list_unref (targets);
+
return row;
}
static GtkWidget*
create_trash_button (void)
{
+ GtkTargetList *targets;
GtkWidget *button;
button = gtk_button_new_with_mnemonic ("_Delete");
+ targets = gtk_target_list_new (button_targets, G_N_ELEMENTS (button_targets));
gtk_drag_dest_set (button,
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
- button_targets,
- G_N_ELEMENTS (button_targets),
+ targets,
GDK_ACTION_MOVE);
+ gtk_target_list_unref (targets);
g_signal_connect_after (G_OBJECT (button), "drag-data-received",
G_CALLBACK (on_button_drag_data_received), NULL);
GtkWidget *window, *toolbar, *grid, *treeview, *scrolled_window;
GtkWidget *hbox, *hbox1, *hbox2, *checkbox, *option_menu, *menu;
gint i;
+ GtkTargetList *targets;
static const gchar *toolbar_styles[] = { "icons", "text", "both (vertical)",
"both (horizontal)" };
GtkToolItem *item;
gtk_box_pack_end (GTK_BOX (hbox), checkbox);
+ targets = gtk_target_list_new (target_table, G_N_ELEMENTS (target_table));
gtk_drag_source_set (button, GDK_BUTTON1_MASK,
- target_table, G_N_ELEMENTS (target_table),
+ targets,
GDK_ACTION_MOVE);
gtk_drag_dest_set (toolbar, GTK_DEST_DEFAULT_DROP,
- target_table, G_N_ELEMENTS (target_table),
+ targets,
GDK_ACTION_MOVE);
+ gtk_target_list_unref (targets);
g_signal_connect (toolbar, "drag_motion",
G_CALLBACK (toolbar_drag_motion), NULL);
g_signal_connect (toolbar, "drag_leave",
GtkCellRenderer *cell;
GtkWidget *swindow;
GtkTreeModel *sample_model;
+ GtkTargetList *targets;
gint i;
gtk_init ();
/* Drag and Drop */
+ targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (left_tree_view),
GDK_BUTTON1_MASK,
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (left_tree_view),
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (top_right_tree_view),
GDK_BUTTON1_MASK,
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (top_right_tree_view),
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (bottom_right_tree_view),
GDK_BUTTON1_MASK,
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE);
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (bottom_right_tree_view),
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE);
-
+ gtk_target_list_unref (targets);
gtk_box_pack_start (GTK_BOX (vbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL));
GtkTreeView *tv;
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
+ GtkTargetList *targets;
tv = (GtkTreeView*) gtk_tree_view_new ();
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_append_column (tv, column);
gtk_tree_view_set_model (tv, get_model ());
- gtk_tree_view_enable_model_drag_source (tv, GDK_BUTTON1_MASK, entries, G_N_ELEMENTS (entries), GDK_ACTION_COPY);
+ targets = gtk_target_list_new (entries, G_N_ELEMENTS (entries));
+ gtk_tree_view_enable_model_drag_source (tv, GDK_BUTTON1_MASK, targets, GDK_ACTION_COPY);
+ gtk_target_list_unref (targets);
return GTK_WIDGET (tv);
}
get_droptarget (void)
{
GtkWidget *label;
+ GtkTargetList *targets;
label = gtk_label_new ("Drop here");
- gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL, entries, G_N_ELEMENTS (entries), GDK_ACTION_COPY);
+ targets = gtk_target_list_new (entries, G_N_ELEMENTS (entries));
+ gtk_drag_dest_set (label, GTK_DEST_DEFAULT_ALL, targets, GDK_ACTION_COPY);
g_signal_connect (label, "drag-data-received", G_CALLBACK (data_received), NULL);
+ gtk_target_list_unref (targets);
return label;
}
GtkWidget *box;
GtkWidget *combo_box;
GtkTreeModel *model;
+ GtkTargetList *targets;
gint i;
gtk_init ();
tv = gtk_tree_view_new_with_model (models[0]);
g_signal_connect (tv, "row-activated", G_CALLBACK (on_row_activated), NULL);
+ targets = gtk_target_list_new (row_targets, G_N_ELEMENTS (row_targets));
gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tv),
GDK_BUTTON1_MASK,
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
gtk_tree_view_enable_model_drag_dest (GTK_TREE_VIEW (tv),
- row_targets,
- G_N_ELEMENTS (row_targets),
+ targets,
GDK_ACTION_MOVE | GDK_ACTION_COPY);
+ gtk_target_list_unref (targets);
/* Model menu */
combo_box = gtk_combo_box_text_new ();